Q: I've implemented a server endpoint which hands the connection off to a
handoff endpoint. After the server processes a connect request using the
OTAccept call, the asynchronous handler for the handoff endpoint is passed a
T_DATA event. When the handler makes the OTRcv call, however, it returns error
-3168, (kOTStateChangeErr ). Can you explain this?
A: This problem only occurs when there is a handoff (secondary) endpoint
involved. The implementation of Open Transport makes it possible for an
asynchronous handoff endpoint to receive a T_DATA event before the connect
mechanism is completed. After accepting a connection, an asynchronous listener
endpoint can expect to receive a T_ACCEPTCOMPLETE call. The "accepting" or
handoff endpoint can expect to receive the T_PASSCON event.
It is possible for the handoff endpoint to receive the T_DATA event before
receiving the T_PASSCON event. If this happens, set a flag to defer receiving
the data until later. When the T_PASSCON event is received, check the flag and
issue the OTRcv call if the flag is set. (Note that after deferring the
handling of the T_DATA event, your handler will not be notified with this
event, until you process (read) all of the data presently available.)
|